/*
 * EntryValue.java
 * version v1.01
 */

package fr.mywiki.model.jdbcAdapter.values;

import java.util.Collection;

import fr.mywiki.model.ejbAdapter.Value;


/**
 * This class represents an entry of the base.
 *
 * @author Thomas
 */

public class EntryValue extends AbstractValueObject{
	private static final long serialVersionUID = 1L;
	/* The fields of the database */
	/** Contains the identifier of the entry. Is also the primary key of the table. */
	public static final String ID = "id";
	/** Contains the intern title of the entry */ 
	public static final String INTERN_TITLE = "internTitle";
	/** Contains the title of the entry. */
	public static final String TITLE = "title";
	/** Contains the entry itself */ 
	public static final String CONTENT = "content";
	
	/**
	 * The type of object represented by an instance of this class.
	 */
	public static final String TYPE = "entry";
	
	/**
	 * The different fields of that kind of object.
	 */
	public static final String[] FIELD_NAMES = { ID, TITLE, CONTENT, INTERN_TITLE };
	
	public static final String IDENTIFIER = ID;
	
	private Long id;
	private String internTitle;
	private String title;
	private String content;

	public String getTypeEnt() {
		return TYPE_ENT;
	}
	
	public Object get(String attName) {
		if (ID.equals(attName))
			return getId();
		if (INTERN_TITLE.equals(attName))
			return getInternTitle();
		if (TITLE.equals(attName))
			return getTitle();
		if(CONTENT.equals(attName))
			return getContent();
		return null;
	}
	
	public void set(String attName,Object value) {
		if(ID.equals(attName))
			setId((Long)value);
		if (INTERN_TITLE.equals(attName))
			setInternTitle((String)value);
		if (TITLE.equals(attName))
			setTitle((String)value);
		if(CONTENT.equals(attName))
			setContent((String)value);
	}
	
	public String getType() {
		return TYPE;
	}

	public String getIdentifierFieldName() {
		return IDENTIFIER;
	}
	
	public String[] getFieldNames() {
		return FIELD_NAMES;
	}
	
	public Object getIdentifier() {
		return get(IDENTIFIER);
	}

	/* Getters/setters */
	
	public String getContent() { return content; }
	public void setContent(String content) { this.content = content; }
	public String getTitle() { return title; }
	public void setTitle(String title) { this.title = title; }
	public Long getId() { return id;	}
	public void setId(Long id) {	this.id = id; }

	public Collection getLinks(String relName) {
		return null;
	}

	public void addLink(String relName, Value added) {
	}

	public void addLinks(String relName, Collection added) {
	}

	public boolean isLinked(String relName, Value linked) {
		return false;
	}

	public void removeLink(String relName, Value removed) {
	}

	public void removeAllLinks(String relName) {
	}

	public String getInternTitle() {
		return internTitle;
	}

	public void setInternTitle(String intern_title) {
		this.internTitle = intern_title;
	}
}
